<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="entity.*,factory.*,dao.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>增加用户！</title>
</head>
<body>
<% 
   User user=new User();
   request.setCharacterEncoding("UTF-8");
   user.setUsername(request.getParameter("username"));
   user.setGender(request.getParameter("gender"));
   user.setAge(Integer.parseInt(request.getParameter("age")));
   user.setEmail(request.getParameter("email"));
   user.setPassword(request.getParameter("password"));
   user.setRegdatetime(new Date()); //让注册日期等于当前日期
             
   if(DAOFactory.getIEmpDAOInstance().add(user)){
	     
  %>
    <script type="text/javascript">
       alert("注册成功，userid是"+<%=user.getUsername()%>+",马上去登录吧"); 
      <% response.setHeader("Refresh", "2;URL=login.jsp");%>
 
    </script>
  <% 
   }
   %>
</body>
</html>